package myPack.GMAO.Bean;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import myPack.GMAO.Entity.Type;
import myPack.GMAO.Interface.TypeInterface;

@Stateless
public class TypeBean implements TypeInterface 
{

	@PersistenceContext
	EntityManager em;
	
	@Override
	public void ajouter(Type t) {
		em.merge(t);
	}

	@Override
	public void supprimer(int idT) {
		em.remove(em.find(Type.class, idT));
	}

	@Override
	public void modifier(int idT, String lib) {
		Type tmp=em.find(Type.class,idT);
		tmp.setLibele(lib);
	}

	@Override
	public Type chercher(int idT) {
		return em.find(Type.class, idT);
	}

	@Override
	public List<Type> lister() 
	{
		return em.createQuery("from Type").getResultList();
	}
}
